/* 
 * Copyright 2010 Ziya Guven Koylu, Ozge Koylu
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at 
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */
package com.koylu.caffein.datasource;

import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import javax.sql.DataSource;

public class GenericDataSource implements DataSource{
	
	private String driver;
	private String url;
	private String user;
	private String password;
	
	public String getDriver() {
		return driver;
	}

	public void setDriver(String driver) {
		this.driver = driver;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getUser() {
		return user;
	}

	public void setUser(String user) {
		this.user = user;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public synchronized Connection getConnection() throws SQLException {
		try {
			Class.forName(driver);
		} catch (ClassNotFoundException e) {
			throw new SQLException(e);
		}
		return DriverManager.getConnection(url, user, password);
	}
	
	public Connection getConnection(String arg0, String arg1) throws SQLException {
		throw new SQLException("not implemented");
	}
	
	public int getLoginTimeout() throws SQLException {
		throw new SQLException("not implemented");
	}

	public PrintWriter getLogWriter() throws SQLException {
		throw new SQLException("not implemented");	
	}

	public void setLogWriter(PrintWriter arg0) throws SQLException {
		throw new SQLException("not implemented");	
	}

	public void setLoginTimeout(int arg0) throws SQLException {
		throw new SQLException("not implemented");
	}

	public boolean isWrapperFor(Class<?> arg0) throws SQLException {
		throw new SQLException("not implemented");
	}

	public <T> T unwrap(Class<T> arg0) throws SQLException {
		throw new SQLException("not implemented");
	}
}